<?	
//LAST MODIFIED AT - 31/10/03 01:25AM	BY 	RIzwAN

	$cmbRank  = $_POST['cmbRank'];
	
	if (isset($_POST['txtComments']))
		$txtComments = $_POST['txtComments'];
	
	$clientId = $_POST['ClientID'];
	if (isset($_POST['Comments_id'])) {
		$Comments_id = $_POST['Comments_id'];
	}
	//$clientId='1';
	
	if (isset($txtComments) && empty($Comments_id))
	{
		$sql = "INSERT INTO er_Comments (comment,comment_datetime,rank, client_id)
					VALUES ('$txtComments', curdate(), '$cmbRank', '$clientId')";
		
		//echo $sql;			
		r_db($sql);
		PRINT "Comment sucessfully created.";
	}
	elseif ($Comments_id > 0 && $_POST['Delete'] == 0) {
		$sql = "UPDATE er_comments SET comment = '$txtComments',comment_datetime = curdate(), rank = '$cmbRank' WHERE Comments_id = $Comments_id";
		
		//echo $sql;
		r_db($sql);
		PRINT "Comment sucessfully modified.";
	}
	elseif ($_POST['Delete'] == 1) {
		$sql = "DELETE FROM er_comments WHERE Comments_id = $Comments_id";
		
		//echo $sql;
		r_db($sql);
		PRINT "Comment sucessfully deleted.";
	}
	
	//echo $queryComments;
	echo "<br /><Br /><a href=\"?page=comment_add&ClientID=$clientId\">Click here to return to comments</a>";
	
?>